﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;
using System.Text;
using NickLee.Common;
namespace GPCSC.Web.CM
{
    public partial class newBS : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                f_build();
            }
        }
        protected void f_build()
        {
            DataSet ds = new DataSet();
            Hashtable htable = new Hashtable();
            byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
            Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
            htable.Add("@postid", users.CL_POSTID_PK.ToString());
            ds = new SqlReadXml().ReaderDataSet("sel_fkls_bypost", htable);
            if (ds != null)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["xs"].ToString() == "1")
                    {
                        dr["xs"] = "已填写";
                    }
                    else
                    {
                        dr["xs"] = "未填写";
                    }
                    if (dr["bgs"].ToString() == "1")
                    {
                        dr["bgs"] = "已填写";
                    }
                    else
                    {
                        dr["bgs"] = "未填写";
                    }
                    if (dr["mq"].ToString() == "" || dr["mq"].ToString() == null)
                    {
                        dr["mq"] = 0;
                    }
                    if (dr["bg"].ToString() == "" || dr["bg"].ToString() == null)
                    {
                        dr["bg"] = 0;
                    }

                    if (dr["IsBs"].ToString() == "0")
                    {
                        dr["title"] = "<strong style='color:red;cursor:pointer' bs='" + dr["HDId"].ToString() + "' onclick='bss(this)' >未报送</strong>";
                        dr["titles"] = "<strong style='color:red; cursor:pointer' del='" + dr["HDId"].ToString() + "' onclick='dels(this)'>退回</strong>";
                    }
                    else if (dr["IsBs"].ToString() == "1")
                    {
                        dr["title"] = "<strong style='color:blue;' >已报送</strong>";
                        dr["titles"] = "";
                    }
                    else if (dr["IsBs"].ToString() == "2")
                    {
                        dr["title"] = "<strong style='color:blue;'>已退回</strong>";
                        dr["titles"] = "";
                    }
                }
            }
            PostListS.DataSource = ds;
            PostListS.DataBind();
        }
        protected void LCallBack_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            try
            {
                string type = e.Parameters[0].ToString();
                if (type == "del")
                {
                    string ids = e.Parameters[1].ToString();

                    Hashtable htable = new Hashtable();
                    htable.Add("IsBs", "2");
                    SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();

                    dtable.databyhtables(htable, "update", "TB_HDQK", "HDId", ids);
                    f_build();
                }
                else if (type == "bs")
                {
                    string bsids = e.Parameters[1].ToString();
                    if (bsids.Length > 1)
                    {
                        Hashtable htable = new Hashtable();
                        htable.Add("IsBs", "1");
                        SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();
                      
                      dtable.databyhtables(htable, "update", "TB_HDQK", "HDId", bsids);
                      
                    }
                    f_build();
                }

            }
            catch (Exception ee)
            {
                throw ee;
            }
            finally
            {
                Panel1.RenderControl(e.Output);
            }

        }
    }
}